//
//  OldPhotoGuideView.m
#import "OldPhotoGuideView.h"
@interface OldPhotoGuideView()
@property (nonatomic,strong) UIButton *oldPhotoGuideBtn;
@property (nonatomic, strong)NSArray * oldPhotoGuideImgs;
@property (nonatomic, assign)int oldPhotoGuideIndex;
@end
@implementation OldPhotoGuideView
-(instancetype)init{
    if (self == [super init]) {
        self.oldPhotoGuideIndex = 0;
        self.oldPhotoGuideImgs = @[@"OldPhotoGuide1",@"OldPhotoGuide2",@"OldPhotoGuide3"];
        [self creatOldPhotoInitView];
    }
    return self;
}
- (void)creatOldPhotoInitView{
    self.oldPhotoGuideBtn = [[UIButton alloc] init];
    [self.oldPhotoGuideBtn setBackgroundImage:OldPhotoImageNamed(self.oldPhotoGuideImgs[self.oldPhotoGuideIndex]) forState:UIControlStateNormal];
    [self.oldPhotoGuideBtn addTarget:self action:@selector(oldPhotoGuideChange) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:self.oldPhotoGuideBtn];
    [self.oldPhotoGuideBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(@(OldPhotoRatio(0)));
    }];
}
- (void)oldPhotoGuideChange{
    self.oldPhotoGuideIndex ++;
    if(self.oldPhotoGuideImgs.count > self.oldPhotoGuideIndex){
        [self.oldPhotoGuideBtn setBackgroundImage:OldPhotoImageNamed(self.oldPhotoGuideImgs[self.oldPhotoGuideIndex]) forState:UIControlStateNormal];
    }else{
        [[NSUserDefaults standardUserDefaults] setObject:@"1" forKey:@"OldPhotoGuideDef"];
        [self removeFromSuperview];
        if (self.OldPhotoGuideFinishBlock) {
            self.OldPhotoGuideFinishBlock();
        }
    }
}
@end
